package com.ruoyi.web.controller.djb;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.djb.domain.DjbChargeGradient;
import com.ruoyi.djb.service.IDjbChargeGradientService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 充值列表Controller
 * 
 * @author xxd
 * @date 2025-03-04
 */
@Controller
@RequestMapping("/djb/djbGradient")
public class DjbChargeGradientController extends BaseController
{
    private String prefix = "djb/djbGradient";

    @Autowired
    private IDjbChargeGradientService djbChargeGradientService;

    @RequiresPermissions("djb:djbGradient:view")
    @GetMapping()
    public String djbGradient()
    {
        return prefix + "/djbGradient";
    }

    /**
     * 查询充值列表列表
     */
    @RequiresPermissions("djb:djbGradient:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(DjbChargeGradient djbChargeGradient)
    {
        startPage();
        List<DjbChargeGradient> list = djbChargeGradientService.selectDjbChargeGradientList(djbChargeGradient);
        return getDataTable(list);
    }

    /**
     * 导出充值列表列表
     */
    @RequiresPermissions("djb:djbGradient:export")
    @Log(title = "充值列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(DjbChargeGradient djbChargeGradient)
    {
        List<DjbChargeGradient> list = djbChargeGradientService.selectDjbChargeGradientList(djbChargeGradient);
        ExcelUtil<DjbChargeGradient> util = new ExcelUtil<DjbChargeGradient>(DjbChargeGradient.class);
        return util.exportExcel(list, "充值列表数据");
    }

    /**
     * 新增充值列表
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存充值列表
     */
    @RequiresPermissions("djb:djbGradient:add")
    @Log(title = "充值列表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(DjbChargeGradient djbChargeGradient)
    {
        return toAjax(djbChargeGradientService.insertDjbChargeGradient(djbChargeGradient));
    }

    /**
     * 修改充值列表
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap)
    {
        DjbChargeGradient djbChargeGradient = djbChargeGradientService.selectDjbChargeGradientById(id);
        mmap.put("djbChargeGradient", djbChargeGradient);
        return prefix + "/edit";
    }

    /**
     * 修改保存充值列表
     */
    @RequiresPermissions("djb:djbGradient:edit")
    @Log(title = "充值列表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(DjbChargeGradient djbChargeGradient)
    {
        return toAjax(djbChargeGradientService.updateDjbChargeGradient(djbChargeGradient));
    }

    /**
     * 删除充值列表
     */
    @RequiresPermissions("djb:djbGradient:remove")
    @Log(title = "充值列表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(djbChargeGradientService.deleteDjbChargeGradientByIds(ids));
    }
}
